<?php
/**
 * Управляем "авторами" документа.
 */

/**
 * Класс Model_ItemAuthor управляет авторами документа.
 *
 * @package Model
 * @author lucky
 */
class Model_ItemAuthor extends RL_Model2
{
	public function getDocuments ($author_oid)
	{
		$items = array();

		$db = $this->store->db;
		$prefix = $db->db_prefix;

		$author_oid_sql = $db->quote($author_oid);
		$sql = "
			SELECT DISTINCT O.* FROM {$prefix}objects O INNER JOIN {$prefix}item_author IA ON (O.oid = IA.item_oid)
			WHERE IA.author_oid = {$author_oid_sql}
			ORDER BY O.ctime
		";
		$rs = $this->store->findSQL( $sql );
		while ($o = $rs->next()) {
			$item = $o->data;
			$item['oid'] = $o->id;
			$items[] = $item;
		}

		return $items;
	} // end of method suggestPerson
}

?>
